﻿@{
    var currentOperator = YunSpace.Core.OperatorProvider.Provider.GetCurrent();
}

<!DOCTYPE html>
<html style="overflow: hidden;">
<head>
    <title>YunSpace快速开发平台</title>
    <link href="~/Content/css/AdminLTE.min.css" rel="stylesheet" />
    <link href="~/Content/css/framework-font.css" rel="stylesheet" />
    <script src="~/Content/js/jquery/jquery-2.1.1.min.js"></script>
    <script src="~/Content/js/bootstrap/bootstrap.js"></script>
    <link href="~/Content/js/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <script src="~/Content/js/dialog/dialog.js"></script>
    <script src="~/Content/js/cookie/jquery.cookie.js"></script>
    <link href="~/Content/css/framework-theme.css" rel="stylesheet" />
    <script src="~/Content/js/framework-ui.js"></script>
    <script src="~/Content/js/framework-clientdata.js"></script>
    <link href="~/Content/css/Font-Awesome/font-awesome.min.css" rel="stylesheet" />
    @*@Scripts.Render("~/roadflow/script")*@
    <script>
        $(function () {
            var userinfo = getCache("DLXX");
            if (userinfo != null && userinfo.F_Gender == true) {
                $("#personImg").attr("src", "/Content/img/samples/robert-300.jpg");
                $("#personImgae").attr("src", "/Content/img/samples/robert-300.jpg");
            }
        });
    </script>
</head>
<body style="overflow: hidden;">
    <div id="ajax-loader" style="cursor: progress; position: fixed; top: -50%; left: -50%; width: 200%; height: 200%; background: #fff; z-index: 10000; overflow: hidden;">
        <img src="~/Content/img/ajax-loader.gif" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto;" />
    </div>
    <div id="theme-wrapper">
        <header class="navbar" id="header-navbar">
            <div class="container" style="padding-right: 0px;">
                <a href="#" id="logo" class="navbar-brand">YUNSPACE CRM</a>
                <div class="clearfix">
                    <div class="nav-no-collapse navbar-left pull-left hidden-sm hidden-xs">
                        <ul class="nav navbar-nav pull-left">
                            <li>
                                <a class="btn" id="make-small-nav"><i class="fa fa-bars"></i></a>
                            </li>
                        </ul>
                    </div>
                    <div class="nav-no-collapse pull-right" id="header-nav">
                        <ul class="nav navbar-nav pull-right">
                            @*<li class="mobile-search">
                                    <a class="btn">
                                        <i class="fa fa-search"></i>
                                    </a>
                                    <div class="drowdown-search">
                                        <form role="search">
                                            <div class="form-group">
                                                <input type="text" class="form-control" placeholder="Search...">
                                                <i class="fa fa-search nav-search-icon"></i>
                                            </div>
                                        </form>
                                    </div>
                                </li>
                                <li class="dropdown hidden-xs">
                                    <a class="btn dropdown-toggle" data-toggle="dropdown">
                                        <i class="fa fa-tasks"></i>
                                        <span class="count">5</span>
                                    </a>
                                </li>
                                <li class="dropdown hidden-xs">
                                    <a class="btn dropdown-toggle" data-toggle="dropdown">
                                        <i class="fa fa-bell"></i>
                                        <span class="count">8</span>
                                    </a>
                                </li>

                                <li class="dropdown hidden-xs">
                                    <a class="btn dropdown-toggle" data-toggle="dropdown">
                                        <i class="fa fa-envelope-o"></i>
                                        <span class="count">16</span>
                                    </a>
                                </li>*@
                            @* <div class="label label-warning" style="display: none" id="refreshUnreadMessageCount"></div>*@
                            <li style="display: none" id="refreshUnreadMessageCount"></li>
                            @*<li class="dropdown notifications-menu">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                    <i class="fa fa-bell-o"></i>
                                    <span class="label label-warning" id="unreadMessageCount"></span>
                                </a>
                                <ul id="" class="dropdown-menu">
                                    <li>
                                        <ul id="unreadMessageTips" class="menu" style="max-width: 190px;"></ul>
                                    </li>
                                </ul>
                            </li>*@
                            @*<li class="dropdown profile-dropdown">
                                    <a href="#" class="dropdown" data-toggle="dropdown">
                                        <i class="icon-envelope"><span style="color: black;"> 0 </span></i>条
                                    </a>

                                    @*<p><i class="icon-envelope"></i> icon-camera-retro</p>
                                </li>*@
                            <li class="dropdown profile-dropdown">

                                <a href="#" class="dropdown" data-toggle="dropdown">
                                    <img id="personImg" src="~/Content/img/samples/scarlet-159.png" alt="" />
                                    <span class="hidden-xs">@(currentOperator == null ? "" : currentOperator.UserCode)</span>
                                </a>
                                <ul class="dropdown-menu pull-right">                                   
                                    <li class="divider"></li>
                                    <li><a href="~/Login/OutLogin"><i class="ace-icon fa fa-power-off"></i>安全退出</a></li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </header>
        <div id="page-wrapper" class="container">
            <div class="row">
                <div id="nav-col">
                    <section id="col-left" class="col-left-nano">
                        <div id="col-left-inner" class="col-left-nano-content">
                            <div id="user-left-box" class="clearfix hidden-sm hidden-xs dropdown profile2-dropdown">
                                <img id="personImgae" alt="" src="~/Content/img/samples/scarlet-159.png" />
                                <div class="user-box">
                                    <span class="name">
                                        @(currentOperator == null ? "" : currentOperator.UserName)
                                    </span>
                                    <span class="status">
                                        <i class="fa fa-circle"></i>在线
                                    </span>
                                </div>
                            </div>
                            <div class="collapse navbar-collapse navbar-ex1-collapse" id="sidebar-nav">
                                <ul class="nav nav-pills nav-stacked">
                                    @*<li class="nav-header hidden-sm hidden-xs">常用菜单
                                            <i class="fa fa-gear" style="color: #868b98; font-size: 12px; margin-top: -6px; position: absolute; right: 23px; top: 50%; cursor: pointer;"></i>
                                        </li>
                                        <li class="common">
                                            <a href="#">
                                                <i class="fa fa-star-o"></i>
                                                <span>联系人</span>
                                            </a>
                                        </li>
                                        <li class="common">
                                            <a href="#">
                                                <i class="fa fa-star-o"></i>
                                                <span>合同</span>
                                            </a>
                                        </li>
                                        <li class="common">
                                            <a href="maps.html">
                                                <i class="fa fa-star-o"></i>
                                                <span>产品</span>
                                            </a>
                                        </li>
                                        <li class="common">
                                            <a href="#">
                                                <i class="fa fa-star-o"></i>
                                                <span>客户</span>
                                            </a>
                                        </li>*@
                                </ul>
                            </div>
                        </div>
                    </section>
                </div>
                <div id="content-wrapper">
                    <div class="content-tabs">
                        <button class="roll-nav roll-left tabLeft">
                            <i class="fa fa-backward"></i>
                        </button>
                        <nav class="page-tabs menuTabs">
                            <div class="page-tabs-content" style="margin-left: 0px;">
                                <a href="javascript:;" class="menuTab active" data-id="/Home/Default">欢迎首页</a>
                                @*<a href="javascript:;" class="menuTab" data-id="/Home/About" style="padding-right: 15px;">平台介绍</a>*@
                            </div>
                        </nav>
                        <button class="roll-nav roll-right tabRight">
                            <i class="fa fa-forward" style="margin-left: 3px;"></i>
                        </button>
                        <div class="btn-group roll-nav roll-right">
                            <button class="dropdown tabClose" data-toggle="dropdown">
                                页签操作<i class="fa fa-caret-down" style="padding-left: 3px;"></i>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right">
                                <li><a class="tabReload" href="javascript:void();">刷新当前</a></li>
                                <li><a class="tabCloseCurrent" href="javascript:void();">关闭当前</a></li>
                                <li><a class="tabCloseAll" href="javascript:void();">全部关闭</a></li>
                                <li><a class="tabCloseOther" href="javascript:void();">除此之外全部关闭</a></li>
                            </ul>
                        </div>
                        <button class="roll-nav roll-right fullscreen"><i class="fa fa-arrows-alt"></i></button>
                    </div>
                    <div class="content-iframe" style="background-color: #f9f9f9; overflow: hidden;">
                        <div class="mainContent" id="content-main" style="margin: 10px; margin-bottom: 0px; padding: 0;">
                            <iframe id="mainTabDiv" class="YunSpace_iframe" width="100%" height="100%" src="/Home/Default" frameborder="0" data-id="/Home/Default"></iframe>
                            <iframe class="YunSpace_iframe" width="100%" height="100%" src="/Home/About" frameborder="0" data-id="/Home/About"></iframe>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="loadingPage" style="display: none;">
        <div class="loading-shade"></div>
        <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
    </div>
    @*<script>
            var mainTab = null;
            var mainDialog = new RoadUI.Window();
            var rootdir = '@Url.Content("~/")';

            $(function () {
                rootdir = "/" == rootdir ? "" : rootdir;
                //if (rolesLength <= 1) {
                //    $("#MyRole").hide();
                //}

                //$('#mainTabDiv').height($(window).height() - 75);
                //$('#treeDiv').height($(window).height() - (rolesLength > 1 ? 133 : 104));

                //$(window).bind('resize', function () {
                //    $('#mainTabDiv').height($(window).height() - 75);
                //    $('#treeDiv').height($(window).height() - (rolesLength > 1 ? 133 : 104));
                //    mainTab.topResize($(window).height() - 101);
                //});

                mainTab = new RoadUI.Tab({ id: "mainTabDiv", replace: true });
                //roleChange(defaultRoleID);
                //openApp("Home/Home", 0, "首页", "index");

                ////初始化主题按钮样式
                //var theme = $.cookies.get("theme_platform") || "BlueLight";
                //changeTheme(theme, false);
            });

            function openApp(url, model, title, id, width, height, isAppendParams) {
                if (!url || url.toString().length == 0) {
                    return;
                }
                if (!id) {
                    id = RoadUI.Core.newid();
                }
                if (width == 0) width = undefined;
                if (height == 0) height = undefined;
                if (isAppendParams) {
                    url += url.indexOf('?') >= 0 ? "&appid=" + id : "?appid=" + id;
                }
                url = rootdir + url;

                switch (parseInt(model)) {
                    case 0:
                        mainTab.addTab({ id: "tab_" + id.replaceAll('-', ''), title: title, src: url });
                        break;
                    case 1:
                        //mainDialog.open({ id: "window_" + id.replaceAll('-', ''), title: title, url: url, width: width || 800, height: height || 460, ismodal: false });
                        $.modalOpen({
                            id: "window_" + id.replaceAll('-', ''),
                            title: title,
                            width: width || '800px',
                            height: height || '460px',
                            url:  url,
                            btn: []
                        });
                        break;
                    case 2:
                        //mainDialog.open({ id: "window_" + id.replaceAll('-', ''), title: title, url: url, width: width || 800, height: height || 460, ismodal: true });
                        $.modalOpen({
                            id: "window_" + id.replaceAll('-', ''),
                            title: title,
                            width: width || '800px',
                            height: height || '460px',
                            url: url,
                            btn: []
                        });
                        break;
                    case 3:
                        RoadUI.Core.open(url, width || 800, height || 460, title);
                        break;
                    case 4:
                        window.showModalDialog(url, null, "dialogWidth=" + (width || 800) + "px;dialogHeight=" + (height || 460) + "px;center=1");
                        break;
                    case 5:
                        window.open(url);
                        break;
                }
            }
        </script>*@
    <script src="~/Content/js/index.js"></script>
    <script src="~/Content/js/indextab.js"></script>
    <script src="~/Content/js/loading/pace.min.js"></script>

    <script>
        var lastMessageCreateDateTime;

        $(function () {
            //messageTip();
            initControls();
            initAttachEvent();
        });

        //消息提示
        //function messageTip() {
        //    var newestUnreadMessage;

        //    //获取最新的未读信息
        //    $.ajax({
        //        url: "/ClientsData/GetNewestUnreadMessage",
        //        dataType: "json",
        //        async: false,
        //        success: function (data) {
        //            if (data) {
        //                newestUnreadMessage = data;
        //                var content = data.F_MessageContent;

        //                if (content) {
        //                    if (content.length > 20) {
        //                        content = content.substring(0, 20) + '...';
        //                    }

        //                    layer.open({
        //                        type: 1,
        //                        shade: false,
        //                        title: newestUnreadMessage == 1 ? "审核通知" : "申请通知",
        //                        content: '<div style="padding: 20px 30px;">' + content + '</div>',
        //                        offset: 'rb',
        //                        time: 5000
        //                    });

        //                }
        //            }
        //        }
        //    });
        //}

        //初始化控件
        function initControls() {
            var $unreadMessageTips = $('#unreadMessageTips');
            $unreadMessageTips.empty();

            $.get('/ClientsData/GetUnreadMessagesJson',
                { lastMessageCreateDateTime: lastMessageCreateDateTime},
                function (result) {
                    var data = result;

                    $('#unreadMessageCount').html(' ' + data.count + ' ');

                    $.each(data.messages,
                        function (i, v) {
                            var content = v.F_MessageContent;

                            if (content.length > 10) {
                                content = content.substring(0, 10) + '...';
                            }

                            var html = '<li><a href="#" onclick="openUnreadMessageDialogBox(\'' + v.F_Id + '\')"><i class="fa fa-warning text-yellow"></i>' + content + '</a></li>';

                            $unreadMessageTips.append(html);
                        });

                    if (data.show) {
                        var newestMessage = data.newestMessage;
                        var content = newestMessage.F_MessageContent;
                        lastMessageCreateDateTime = newestMessage.F_CreatorTime;

                        if (content) {
                            if (content.length > 20) {
                                content = content.substring(0, 20) + '...';
                            }

                            layer.open({
                                type: 1,
                                shade: false,
                                title: newestMessage.F_MessageType == 1 ? "审核通知" : "申请通知",
                                content: '<div style="padding: 20px 30px;">' + content + '</div>',
                                offset: 'rb',
                                time: 3000
                            });

                        }
                    }
                });
        }

        //初始化绑定事件
        function initAttachEvent() {
            $('#refreshUnreadMessageCount').click(function () {
                initControls();
            });
        }

        //打开未读消息弹窗
        function openUnreadMessageDialogBox(id) {
            $.post('/ClientsData/SetMessageForReaded',
                { keyValue: id },
                function () {
                    var opt = {
                        id: "editForm",
                        title: '未读消息',
                        url: "/ClientsData/UnreadMessageFrom?keyValue=" + id,
                        width: "500px",
                        height: "200px",
                        btn: null,
                        callBack: function (iframeId) {
                            var result = top.frames[iframeId].submitForm();
                            $('#loadingPage').remove();
                        }
                    };

                    $.modalOpen(opt);
                    $('#refreshUnreadMessageCount').trigger('click');
                });
        }


        setInterval(function () {
            //messageTip();
            initControls();
        }, 300000);    //5分钟
    </script>
</body>
</html>
